package cn.tedu.zx.product.webapi.web;

import cn.tedu.zx.product.webapi.ex.ServiceCode;
import lombok.Data;
import lombok.experimental.Accessors;

@Data
@Accessors(chain = true)/*创建setter时将返回值设置为当前对象（JsonResult）*/
public class JsonResult {
    private Integer state;
    private String message;
    private Object data;


    public static JsonResult success() {
        return success(null);
    }


    public static JsonResult success(Object data) {
        JsonResult result = new JsonResult();
        result.setState(ServiceCode.OK.getValue());
        result.setData(data);
        result.setMessage("成功");
        return result;
    }
    public static JsonResult fail(ServiceCode state,String message) {
        JsonResult result = new JsonResult();
        result.setState(state.getValue());
        result.setMessage(message);
        return result;
    }

}
